/*
 *  Laboratorio de Finanzas Computacionales
 */

package bm.actions;

import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

import bm.data.Libro;


public class ListaLibros extends Action {
    
    
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        
        Vector<Libro> libros = this.getLibros();
        request.setAttribute("libros", libros);
        
        return mapping.findForward("success");
    }
    
    
    
    
    
    private Vector<Libro> getLibros() {
        Vector v = new Vector();
        
        Libro l1 = new Libro("El Codigo Da Vinci", "Dan Brown");
        l1.setPaginas(560);
        v.add(l1);
        
        Libro l2 = new Libro("El Hobbit", "Tolkien");
        l2.setPaginas(368);
        v.add(l2);
        
        Libro l3 = new Libro("Estado de miedo", "Michael Crichton");
        v.add(l3);
        
        return v;
    }
    
    
    
}
